package DataStructures;


public class Stack <T> {
	
	Node <T> tos;
	
	public Stack (){
		
		tos = null;
	}
	
	public void push(T e){
		
		Node <T> temp = new Node<T>(e);
		temp.next = tos;
		tos = temp;
	}
	
	public boolean isEmpty(){
		
		boolean result = false;
		if(tos == null)
			result = true;
		return result;
	}
	
	public T pop(){
		
		T val = null;
		if (!isEmpty()){
			val = tos.data;
			tos = tos.next;
		}
		return val;
	}
	
	public void print (){
		
		Node <T> run = tos;
		while (run != null){
			System.out.println(run.data);
			run = run.next;
		}
	}
}
